<?php echo $this->element('displayHeader'); ?>
<div class="toolbar"><?php echo $this->element('toolbar', array('buttons' => array('add', 'refresh'))); ?></div>

<?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
<?php echo $this->element('dataNotFound'); ?>
<? else : // ถ้ามีข้อมูล ?>
<?php $paginator->options(array('update' => 'content', 'indicator' => 'indicator')); ?>
<?php echo $this->element('dataCaptionLimit'); ?>
<?php $cur = $paginator->counter(array('format' => '%start%')); ?>

<table class="data">
    <thead>
        <tr>
            <th class="no"><?php echo $paginator->sort('No', 'id'); ?></th>
            <th width="100px"><?php echo $paginator->sort('Retrieve no.', 'IRH.retrieve_no'); ?></th>
            <th width="100px"><?php echo $paginator->sort('Retrieve date', 'IRH.retrieve_date'); ?></th>
            <th><?php echo $paginator->sort('Ref. by Customer return no.', 'CRH.return_no'); ?></th>
            <th><?php echo $paginator->sort('Vendor Document no.', 'CRH.vendor_document_no'); ?></th>
            <th><?php echo $paginator->sort('Site', 'Site.name'); ?></th>
            <th><?php echo $paginator->sort('Customer', 'Customer.name'); ?></th>
            <th><?php echo $paginator->sort('Status', 'retrieve_status_id'); ?></th>
            <th><?php echo $paginator->sort('Retrieve by', 'retrieve_by'); ?></th>
            <th class="action">&nbsp;</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach($this->data as $key => $data): ?>
        <?php
        $tableCell = array();
        $tableCell[] = $cur++;
        $tableCell[] = $data['IRH']['retrieve_no'];
        $tableCell[] = $data['IRH']['retrieve_date'];
        $tableCell[] = $data['CRH']['return_no'];
        $tableCell[] = (!empty($data['CRH']['vendor_document_no'])? $data['CRH']['vendor_document_no']: '-');
        $tableCell[] = $data['Site']['name'];
        $tableCell[] = $data['Customer']['name'];
        $tableCell[] = $data['RS']['title'];
        $tableCell[] = $data['IRH']['retrieve_by'];
        $tableCell[] = $ajax->link($html->image('icon/edit.png', array('title' => 'edit', 'alt' => 'edit')), 'view/' . $data['IRH']['id'],
            array('indicator' => 'indicator', 'update' => 'content'), null, false );
        echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
        ?>
        <?php endforeach; ?>
    </tbody>
</table>
<?php echo $this->element('paging'); ?>
<? endif; ?>
<?php //debug($this->data); ?>